package com.alks.function.controller.common;

import com.alks.common.utils.beanutils.ObjectUtils;
import com.alks.entity.exception.ServiceErrorException;
import com.alks.function.data.dto.procurement.PurchaseOrderDto;
import com.alks.function.data.request.procurement.LotAndMtlRequest;
import com.alks.function.mapper.procurement.MaterialClearanceMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;

/**
 * 调用采购模块的公共类
 */
@Component
public class ProcurementUtills {

    @Resource
    private MaterialClearanceMapper materialClearanceMapper;

    /**
     * 判断指令或者材料是否被采购。
     */
    public boolean isProcurement(LotAndMtlRequest request) {
        List<PurchaseOrderDto>  list = materialClearanceMapper.getPurchaseOrder(request);
        if(ObjectUtils.isNotEmpty(list)){
            throw new ServiceErrorException("该指令或材料已存在订购单！");
        }
        return true;
    }
}
